package com.jy.api.controller.admin;

import com.jy.api.service.PartitionService;
import com.jy.api.signUpReq.admin.PartitionReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * Created by xiaohua on 2019/2/18.
 */
@Slf4j
@RestController
@RequestMapping(value = "v1/admin/par", produces = "application/json;charset=utf-8")
public class PartitionController {

    @Autowired
    private PartitionService partitionService;

    @GetMapping("all")
    public ResponseEntity getAllPar(@RequestParam("storeId") String storeId) {
        return ResponseEntity.ok(partitionService.getAllPar(storeId));
    }

    @PostMapping("add")
    public ResponseEntity addPar(@RequestBody PartitionReq req) {
        return ResponseEntity.ok(partitionService.addPar(req));
    }

    @PostMapping("delete")
    public ResponseEntity deletePar(@RequestBody PartitionReq req) {
        return ResponseEntity.ok(partitionService.deleteParById(req));
    }

    @PostMapping("update")
    public ResponseEntity updatePar(@RequestBody PartitionReq req) {
        return ResponseEntity.ok(partitionService.updateParById(req));
    }


}
